package com.leon.android.component.workmanager_test.task

import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.apkfuns.logutils.LogUtils
import com.leon.android.component.workmanager_test.api.RollToolsApi
import java.lang.Exception

/**
 * @time:2019/12/12 15:13
 * @author:Leon
 * @description:
 */
class UploadWorker(appContext: Context, workerParameters: WorkerParameters) :
    Worker(appContext, workerParameters) {

    private val rollToolsApi = RollToolsApi.getApi()

    override fun doWork(): Result {
        LogUtils.d(inputData.getString("type"))
        try {
            val result = rollToolsApi.getWeatherForecast("杭州市").execute()
            LogUtils.d(result)
        } catch (e: Exception) {
            return Result.retry()
        }

        LogUtils.d("succeed")


        return Result.success()
    }
}